import React, { Component, PropTypes } from 'react';
import echarts from 'echarts';

class EChartsView extends Component {

    componentDidMount() {
        const dataSource = this.props.dataSource;
        var changeTitle = [];
        for(var i = 0;i<dataSource.length;i++){
            changeTitle.push(dataSource[i].projecting); 
        }
        var myChart = echarts.init(document.getElementById('main'));
        // 绘制图表
        myChart.setOption({
            title: { text: '' },
            tooltip: {},
            xAxis: {
                data: changeTitle
            },
            yAxis: {},
            series: [{
                name: '数量',
                type: 'bar',
                data: [2, 4, 9, 10, 5]
            }]
        });
    }

    render() {
        return(
            <div id="main" style={{height:300}}></div>
        );
    }
}

export default  EChartsView;